﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YogaStudio.Data.Domain;
using YogaStudio.Data;

namespace YogaStudio.Service.BLL
{
   public class SemesterService : ISemester
    {
       YogaStudioEntities db;

       public SemesterService()
       {
           db = new YogaStudioEntities();
        }

       public List<Semester> GetAllSemesters()
       {
           return db.Semesters.ToList();
       }

       public bool DeleteSemeter(Semester semester)
       {
           db.Semesters.Remove(semester);
           db.SaveChanges();
           return true;
       }

       public Semester GetSemester(int id)
       {
           return db.Semesters.Find(id);

       }
       public bool DeleteSemester(Semester semester)
       {
           if (semester == db.Semesters.Remove(semester))
           {
               db.SaveChanges();
           }
           return true;

       }
       public void UpdateSemester(Semester semester)
       {
           db.Entry(semester).State = EntityState.Modified;
           db.SaveChanges();
       }
       public bool SaveSemeter (Semester semester)
       {
           db.Semesters.Add(semester);
           db.SaveChanges();
           return true;
       }
       public void Dispose(bool disposing)
       {
           db.Dispose();

       }
    }
}
